//导入 request 函数
import request from '@utils/http/request'
import { HospitalSetItem, ReqAddHospitalSetParams, ReqGetHospitalSetParams, ReqGetHospitalSetResponse, ReqUpdateHospitalSetParams } from './model/hospitalSetTypes';

//发送请求获取医院设置信息
export function reqGetHospitalSet(hospitalSet: ReqGetHospitalSetParams){
  //获取各个参数
  let {page, limit, hosname, hoscode} = hospitalSet;
  //发送请求               这里用来约束返回 promise 对象成功结果值的类型
  return request.get<any, ReqGetHospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    params: {
      hosname: hosname,
      hoscode: hoscode
    }
  });
}

//发送请求新增医院设置
export function reqAddHospitalSet(hospitalSet: ReqAddHospitalSetParams){
  return request.post<any, null>('/admin/hosp/hospitalSet/save', hospitalSet);
}

//发送请求获取医院设置的详细信息
export function reqGetHospitalSetItem(id: string){
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

//更新医院设置信息
export function reqUpdateHospitalSet(hospital: ReqUpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', hospital);
}

//删除医院设置
export function reqRemoveHospitalSet(id: string){
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
}

//批量删除医院的设置信息
export function reqBatchRemoveHospitalSet(ids: number[]){
  //delete 发送请求体数据
  return request.delete('/admin/hosp/hospitalSet/batchRemove', {
    data: ids
  })
}